import Page
from Page import Map
from Base.Base import Base
from selenium.webdriver.common.by import By


class MapIndexPage(Base):
    """
    地图首页

    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 左侧的home键
        self.map_home_btn = (By.XPATH, Map.RESOURCE_ID.format("rl_navigation_home"))

        # 左侧的返回键
        self.map_back_btn = (By.XPATH, Map.RESOURCE_ID.format('rl_navigation_back'))

        # 搜索按钮
        self.map_search_btn = (By.XPATH, Map.RESOURCE_ID.format("rl_search"))

        # 搜索文案
        self.map_search_title_text = (By.XPATH, Map.RESOURCE_ID.format("tv_go_where"))

        # 搜索图标
        self.map_search_cover_img = (By.XPATH, Map.RESOURCE_ID.format("iv_search"))

        # 菜单键
        self.map_menu_btn = (By.XPATH, Map.RESOURCE_ID.format("rl_menu"))

        # 当前定位框按钮
        self.map_current_position_btn = (By.XPATH, Map.RESOURCE_ID.format("rl_car_position"))

        # 定位图标文案
        self.map_current_position_cover_text = (By.XPATH, Map.RESOURCE_ID.format("tv_car_position"))

        # 路况按钮
        self.map_traffic_btn = (By.XPATH, Map.RESOURCE_ID.format("map_tmc"))

        # 指向按钮
        self.map_pointing_btn= (By.XPATH, Map.RESOURCE_ID.format("iv_compass"))

        # 放大按钮
        self.map_amplification_btn = (By.XPATH, Map.RESOURCE_ID.format("rl_zoom_in"))

        # 缩小按钮
        self.map_zoom_out_btn = (By.XPATH, Map.RESOURCE_ID.format("rl_zoom_out"))

        # 比例尺
        self.map_scale_img = (By.XPATH, Map.RESOURCE_ID.format("map_scale"))

    def click_home(self):
        """
        点击左侧的home键

        :return:None
        """
        self.click_element(self.map_home_btn)

    def click_back(self):
        """
        点击左侧的back键

        :return:None
        """
        self.click_element(self.map_back_btn)

    def click_search(self):
        """
        点击搜索按钮

        :return:None
        """
        self.click_element(self.map_search_btn)

    def click_menu(self):
        """
        点击菜单按钮

        :return:None
        """
        self.click_element(self.map_menu_btn)

    def click_current_position(self):
        """
        点击定位按钮

        :return:None
        """
        self.click_element(self.map_current_position_btn)

    def click_traffic(self):
        """
        点击路况按钮

        :return:None
        """
        self.click_element(self.map_traffic_btn)

    def click_pointing(self):
        """
        点击指向按钮

        :return:None
        """
        self.click_element(self.map_pointing_btn)

    def click_amplification(self):
        """
        点击放大按钮

        :return:None
        """
        self.click_element(self.map_amplification_btn)

    def click_zoom_out(self):
        """
        点击缩小按钮

        :return:None
        """
        self.click_element(self.map_zoom_out_btn)

    def get_search_title(self):
        """
        获得搜索文案

        :return:获取元素
        """
        return self.find_element_o(self.map_search_title_text)

    def get_search_cover(self):
        """
        获得搜索图标

        :return:获取元素
        """

        return self.find_element_o(self.map_search_cover_img)

    def get_position_cover(self):
        """
        获得当前定位文案

        :return:获取元素
        """
        return self.find_element_o(self.map_current_position_cover_text)

    def get_scale(self):
        """
        获得当前比例尺

        :return:获取元素
        """
        return self.find_element_o(self.map_scale_img)

    def is_display_map_index(self):
        """
        查看是否进入地图首页

        :return:
        """
        return self.is_display(self.map_menu_btn)
